//
//  UIImageView+WebImage.swift
//  SFWeiboPro
//
//  Created by happy on 2017/9/22.
//  Copyright © 2017年 happy. All rights reserved.
//

import SDWebImage


extension UIImageView {
    
    func sf_setImage(urlString: String?, placeholderImage: UIImage?, isAvtar: Bool = false) {
        
        guard let urlString = urlString,
            let url = URL(string: urlString) else {
            
            image = placeholderImage
            
            return
            
        }
        
        sd_setImage(with: url, placeholderImage: placeholderImage, options: []) { [weak self](image, _, _, _) in
            
            if isAvtar {
                self?.image = image?.setupCycleImage(size: (self?.bounds.size)!)
            }
        }
        
    }
    
}
